<template>
  <div class="header-container">
    <div class="l-content">
      <el-button icon="el-icon-menu" size="mini" @click="handlemenu" circle></el-button>
      <el-breadcrumb separator="/">
        <el-breadcrumb-item v-for="item in tags" :key="item.path" :to="{ path: item.path }">{{ item.label }}</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="r-content">
      <el-dropdown @command="handleCommand">
        <span class="el-dropdown-link">
          <img src="../img/clothes_goods_1.jpg" alt="" />
        </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item>个人中心</el-dropdown-item>
          <el-dropdown-item command="backlogin">退出</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
  </div>
</template>

<script>
import Cookie from 'js-cookie'
import { mapState } from 'vuex'
export default {
  methods: {
    handlemenu() {
      this.$store.commit('changemenu')
    },
    handleCommand(command) {
      if (command === 'backlogin') {
        Cookie.remove('token')
        Cookie.remove('menu')
        this.$router.replace('/login')
      }
    }
  },
  computed: {
    ...mapState({
      tags: state => state.tab.tabList
    })
  }
}
</script>

<style lang="less" scoped>
.header-container {
  padding: 0 20px;
  background-color: #333;
  height: 60px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .l-content {
    display: flex;
    align-items: center;
    .el-button {
      margin-right: 20px;
      border-radius: 10%;
      width: 40px;
    }
    ::v-deep .el-breadcrumb span:last-child {
      .el-breadcrumb__inner {
        &.is-link {
          color: white;
        }
      }
    }
    ::v-deep .el-breadcrumb__item {
      .el-breadcrumb__inner {
        &.is-link {
          color: #666;
        }
      }
    }
    span {
      color: white;
      font-size: 14px;
      margin-left: 10px;
    }
  }
  .r-content {
    img {
      width: 40px;
      height: 40px;
      object-fit: contain;
      border-radius: 50%;
    }
  }
}
</style>
